package com.tankbattle.stage.body.power;


import com.tankbattle.enums.PowerEnum;
import com.tankbattle.stage.body.tank.Tank;

/**
 * 道具
 * @author 13797
 */
public class Power {
    Boolean alive;
    private int x;
    private int y;
    private PowerEnum type = PowerEnum.NO_POWER;

    public Power(int x, int y) {
        super();
        this.x = x;
        this.y = y;
        this.alive = true;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Boolean getAlive() {
        return alive;
    }

    public void setAlive(Boolean alive) {
        this.alive = alive;
        if (!this.getAlive()) {
            // release
            for (int i = 0; i < 32; i++) {
                for (int j = 0; j < 32; j++) {
                    if (Tank.tanks[this.getX() + i][this.getY() + j] >= 6) {
                        Tank.tanks[this.getX() + i][this.getY() + j] = 0;
                    }
                }
            }
        }
    }

    public PowerEnum getType() {
        return type;
    }

    public void setType(PowerEnum type) {
        this.type = type;
    }


}
